{% extends "base.html" %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}

{% block headtitle %}{% trans "Search Results" %}{% endblock %}

{% block head %}
<style>
#cse {
  width: 100%;
  font-size: 48px;
  font-weight: 300;
}
.gsc-control-cse {
  background: #fff;
  padding: 1.5em 2em;
  box-sizing: border-box;
}
.gsc-tabHeader.gsc-tabhInactive {
  border-color: #777777;
  background-color: #777777;
}
.gsc-tabHeader.gsc-tabhActive {
  border-color: #333333;
  background-color: #333333;
}
.gsc-tabsArea {
  border-color: #333333;
}
.gsc-webResult.gsc-result,
.gsc-results .gsc-imageResult {
  border-color: #FFFFFF;
  background-color: #FFFFFF;
}
.gsc-webResult.gsc-result:hover,
.gsc-imageResult:hover {
  background-color: #f5f5f5;
}
.gs-webResult.gs-result a.gs-title:link,
.gs-webResult.gs-result a.gs-title:link b,
.gs-imageResult a.gs-title:link,
.gs-imageResult a.gs-title:link b {
  color: #3D5C9D;
}
.gs-webResult.gs-result a.gs-title:visited,
.gs-webResult.gs-result a.gs-title:visited b,
.gs-imageResult a.gs-title:visited,
.gs-imageResult a.gs-title:visited b {
  color: #3D5C9D;
}
.gs-webResult.gs-result a.gs-title:hover,
.gs-webResult.gs-result a.gs-title:hover b,
.gs-imageResult a.gs-title:hover,
.gs-imageResult a.gs-title:hover b {
  color: #3D5C9D;
}
.gs-webResult.gs-result a.gs-title:active,
.gs-webResult.gs-result a.gs-title:active b,
.gs-imageResult a.gs-title:active,
.gs-imageResult a.gs-title:active b {
  color: #3D5C9D;
}
.gsc-cursor-page {
  color: #3D5C9D;
}
a.gsc-trailing-more-results:link {
  color: #3D5C9D;
}
.gs-webResult .gs-snippet,
.gs-imageResult .gs-snippet {
  color: #333333;
}
.gs-webResult div.gs-visibleUrl,
.gs-imageResult div.gs-visibleUrl {
  color: #0E774A;
}
.gs-webResult div.gs-visibleUrl-short {
  color: #0E774A;
}
.gs-webResult div.gs-visibleUrl-short {
  display: none;
}
.gs-webResult div.gs-visibleUrl-long {
  display: block;
}
.gsc-cursor-box {
  border-color: #FFFFFF;
}
.gsc-results .gsc-cursor-box .gsc-cursor-page {
  border-color: #777777;
  background-color: #FFFFFF;
  color: #3D5C9D;
}
.gsc-results .gsc-cursor-box .gsc-cursor-current-page {
  border-color: #333333;
  background-color: #333333;
  color: #3D5C9D;
}
.gs-promotion {
  border-color: #CCCCCC;
  background-color: #E6E6E6;
}
.gs-promotion a.gs-title:link,
.gs-promotion a.gs-title:link *,
.gs-promotion .gs-snippet a:link {
  color: #0000CC;
}
.gs-promotion a.gs-title:visited,
.gs-promotion a.gs-title:visited *,
.gs-promotion .gs-snippet a:visited {
  color: #0000CC;
}
.gs-promotion a.gs-title:hover,
.gs-promotion a.gs-title:hover *,
.gs-promotion .gs-snippet a:hover {
  color: #444444;
}
.gs-promotion a.gs-title:active,
.gs-promotion a.gs-title:active *,
.gs-promotion .gs-snippet a:active {
  color: #00CC00;
}
.gs-promotion .gs-snippet,
.gs-promotion .gs-title .gs-promotion-title-right,
.gs-promotion .gs-title .gs-promotion-title-right *  {
  color: #333333;
}
.gs-promotion .gs-visibleUrl,
.gs-promotion .gs-visibleUrl-short {
  color: #00CC00;
}
</style>

<script type="text/javascript"
      src="//www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221%22%2C%22language%22%3A%22{{LANGUAGE_CODE}}%22%7D%5D%7D"></script>

<script>
function parseQueryFromUrl() {
  var queryParamName = 'q';
  if ('getParameter' in location) {
    return location.getParameter(queryParamName); // Use native if it is available.
  } else {
    var search = window.location.search.substr(1);
    var parts = search.split('&');
    for (var i = 0; i < parts.length; i++) {
      var keyvaluepair = parts[i].split('=');
      if (decodeURIComponent(keyvaluepair[0]) == queryParamName) {
        return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' '));
      }
    }
    return '';
  }
}

function setupSearch() {
  var customSearchControl = new google.search.CustomSearchControl('007435387813601113811:ef_kuvvx6a8');
  customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  var options = new google.search.DrawOptions();
  options.setAutoComplete(true);
  options.enableSearchResultsOnly();
  customSearchControl.draw('cse', options);
  var queryFromUrl = parseQueryFromUrl();
  if (queryFromUrl) {
    customSearchControl.execute(queryFromUrl);
  }
}

$(window).load(function() {
  setupSearch();
});
</script>
{% endblock %}

{% block body %}
<div id="cse">{% trans "Loading" %}</div>
{% endblock %}

